package com.hspedu.newData.剑指offer;

import java.util.HashSet;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-04 
 * @Version: 1.0
 */

public class LCR120寻找文件副本 {

    // todo
    // 原地交换
    public int findRepeatDocument(int[] documents) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < documents.length; i++) {
            if (set.contains(documents[i])){
                return documents[i];
            }
            set.add(documents[i]);
        }
        return -1;
    }
}
